﻿{% extends "base.html" %}
{% block title %} 上传附件 {% endblock %}
{% block user %} 上传附件 {% endblock %}
{% block styles %}{{super()}}
<link href="{{ url_for('static', filename='drag/css/main.css') }}" rel="stylesheet">
<style>
    .col-center-block {
        float: none;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
</style>
{% endblock %}
{% block scripts %}{{super()}}
{#    <script src="{{ url_for('static', filename='drag/js/dropzone.js') }}"></script>#}
<script src="{{ url_for("static", filename="js/dropzone.js') }}" ) }}"></script>
<script>
    (function () {
        $("#dropzone").dropzone({
            url: 'attachment',
            width: 300,
            height: 300,
            margin: 5,
            progressBarWidth: 300,
            maxFileSize: '500MB',
            allowedFileTypes: '*',
            showTimer: true,
            removeComplete: true,
            params: {
            },
            success: function (res, index) {
                console.log(res, index);
            }
        });
    }());
</script>

{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="main">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-center-block">


                <div class="panel panel-info" width=300>
                    <div class="panel-heading">请拖入需要上传的文件</div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-xs-10 col-sm-6 col-md-4 col-lg-4">
                                <div id="dropzone"></div>
                            </div>
                            <div class="col-xs-6 col-sm-6 col-md-8 col-lg-8">
                                {% include 'flash_message.html' %}
                                <button class="btn btn-warning" onclick="javascript:history.go(-1)">返回</button>
                                <button class="btn btn-success" onclick="javascript:location.reload();">刷新页面</button>

                                <table class="table table-striped table-hover table-bordered">
                                    <tr>
                                        <th>id</th>
                                        <th>文件名</th>
                                        <th>上传时间</th>
                                        <th>删除时间</th>
                                        <th>状态</th>
                                    </tr>

                                    {% for attachment in attachments %}
                                    {%  if attachment.delete %}
                                    <tr class="danger">
                                        {% else %}
                                    <tr class="success">
                                        {% endif %}
                                        <td>{{ attachment.id }}</td>
                                        <td><a download="{{ attachment.display_name }}" href="{{ url_for('bp_partner.download',
                                                   file_name=attachment.file_name,
                                                   attachment_id=attachment.id) }}">{{ attachment.display_name }}
                                            </a>
                                        </td>
                                        <td>{{ attachment.create_time }}</td>
                                        <td>{{ attachment.edit_time }}</td>
                                        <td>
                                            {%  if not attachment.delete %}
                                            <a
                                                href="{{ url_for('bp_partner.attachment_delete', attachment_id=attachment.id) }}">删除</a>
                                            {% else %}
                                            作废
                                            {% endif %}
                                        </td>
                                    </tr>
                                    {% endfor %}
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}